package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.CityDAO;
import com.pojo.City;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CityService extends ServiceImpl<CityDAO, City> {

    @Autowired
    private CityDAO cityDAO;

    /**
     * 根据已选省份查询所有城市
     * @param provincecode 省份code
     * @return
     * city 存入redis缓存
     */
    @Cacheable(value = "city")
    public List<City> findCity(String provincecode){
        QueryWrapper queryWrapper = new QueryWrapper();
        if (provincecode != null){

            queryWrapper.eq("provincecode",provincecode);
        }
        List list = cityDAO.selectList(queryWrapper);
        return list;
    }



}
